<?php

use App\Admin\Controllers\Core\BatchJobController;
use App\Admin\Controllers\Core\FailedJobController;
use App\Admin\Controllers\Core\JobController;
use App\Admin\Controllers\Core\MessageController;
use App\Admin\Controllers\Core\UploadController;
use App\Admin\Controllers\HomeController;
use App\Admin\Controllers\TestController;
use Dcat\Admin\Admin;
use Illuminate\Routing\Router;
use Illuminate\Support\Facades\Route;

Admin::routes();

Route::group([
    'prefix' => config('admin.route.prefix'),
    'namespace' => config('admin.route.namespace'),
    'middleware' => config('admin.route.middleware'),
], function (Router $router) {
    $router->get('/', [HomeController::class, 'index'])
        ->name('index');
    # 队列相关
    $router->get('jobs', [JobController::class, 'index']);
    $router->get('jobs/batches', [BatchJobController::class, 'index']);
    $router->get('jobs/failed', [FailedJobController::class, 'index']);
    $router->delete('jobs/failed/{ids}', [FailedJobController::class, 'destroy']);

    $router->get('test', [TestController::class, 'index']);

    $router->get('messages', [MessageController::class, 'index'])
        ->name('messages.index');
    $router->delete('messages/{id}', [MessageController::class, 'destroy'])
        ->name('messages.destroy');
    $router->get('messages/{notification}', [MessageController::class, 'show'])
        ->name('messages.show');
    $router->post('upload/editor', [UploadController::class, 'editor'])
        ->name('upload.editor');

    foreach (glob(admin_path('Routes').'/*.php') as $routeFile) {
        require $routeFile;
    }
});
